package org.stvd.service.workflow.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.workflow.WfLogs;
import org.stvd.repository.workflow.WfLogsAffixDao;
import org.stvd.repository.workflow.WfLogsDao;
import org.stvd.service.base.impl.BaseServiceImpl;
import org.stvd.service.workflow.WfLogsService;

@Service("WfLogsService")
public class WfLogsServiceImpl extends BaseServiceImpl<WfLogs> implements WfLogsService {

    @Resource(name = "WfLogsDao")
    private WfLogsDao wfLogsDao;

    @Resource(name = "WfLogsAffixDao")
    private WfLogsAffixDao wfLogsAffixDao;

    public QueryResult<WfLogs> getQueryResult(int start, int limit) {
        return wfLogsDao.getQueryResult(start, limit);
    }

    public List<WfLogs> findByProcInstId(String procInstId) {
        List<WfLogs> list = wfLogsDao.findByProcInstId(procInstId);
        for (WfLogs wfLogs : list) {
            wfLogs.setAffixList(wfLogsAffixDao.findByLogId(wfLogs.getId()));
        }
        return list;
    }
}
